/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

/**
 * <p>Project: javaseapp - Stream2
 * <p>Powered by webrx On 2021-08-23 09:10:51
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Stream2 {
    public static void main(String[] args) {
        var sm = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 8, 8, 9, 10, 11, 12);
        //sm.filter(e -> e % 2 == 0).distinct().skip(2).limit(3).forEach(System.out::println);
        //filter() 2 4 6 8 4 6 8 8 8 10 12
        //distinct() 2 4 6 8 10 12
        //skip(2)  6 8 10 12
        //.limit(3) 6 8 10
        //sm.filter(e->e%2==0).distinct().skip(2).limit(4).map(e->e*10).forEach(System.out::println);

        var sm2 = Stream.iterate(1, e -> e + 2).limit(6);
        AtomicInteger space = new AtomicInteger(15);
        sm2.forEach(e -> System.out.println(" ".repeat(space.decrementAndGet()) + "*".repeat(e)));

    }
}
